package yt.kpool.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.king.base.adapter.ViewHolderAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

import yt.kpool.R;
import yt.kpool.activity.setting.EditAccountActivity;
import yt.kpool.activity.setting.OnlyReadActivity;
import yt.kpool.bean.ApiKeyBean;
import yt.kpool.bean.RecommendCustomersBean;


/**
 * ApiKey列表适配器
 * Created by Administrator on 2017/7/17.
 */

public class ApiKeyListviewAdapter extends ViewHolderAdapter<ApiKeyBean.DataBean> {


    private String ChildAccountId;
    private String ChildAccountName;
    public ApiKeyListviewAdapter(Context context, List<ApiKeyBean.DataBean> listData,String ChildAccountId,String ChildAccountName) {
        super(context, listData);
        this.ChildAccountId=ChildAccountId;
        this.ChildAccountName=ChildAccountName;
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ApiKeyBean.DataBean dataBean, int position) {
        return layoutInflater.inflate(R.layout.item_apikey,null);
    }

    @Override
    public void bindViewDatas(ViewHolder holder, final ApiKeyBean.DataBean dataBean, int position) {
        holder.setText(R.id.tv_remark,dataBean.getRemark().equals("")?"无备注":dataBean.getRemark());
        holder.setText(R.id.tv_apikey,dataBean.getAPIKey());

        holder.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                OnlyReadActivity.start((Activity) context, ChildAccountId,dataBean.getRemark(),dataBean.getCreateTime(),dataBean.getAPIKey(),dataBean.getUrl(),ChildAccountName,dataBean.getID()+"");
            }
        });
    }

}
